﻿using Microsoft.AspNetCore.Http;
using System;
using System.Net.Http;

namespace TomNet.Core
{
    public abstract class ServiceBase
    {
        protected readonly IHttpContextAccessor _httpContext;
        protected readonly IHttpClientFactory _httpClientFactory;

        public ServiceBase(
            IHttpContextAccessor httpContext,
            IHttpClientFactory httpClientFactory)
        {
            _httpContext = httpContext;
            _httpClientFactory = httpClientFactory;
        }

        protected IHeaderDictionary GetHeaders()
        {
            return _httpContext.HttpContext.Request.Headers;
        }

        protected HttpClient GetHttpClient()
        {
            return _httpClientFactory.CreateClient("InternalAccess");
        }
    }
}
